package com.lancoo.znbkxx.teacher.ui.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.ClassStuCognitiveDiagnosisInfor
import com.lancoo.znbkxx.teacher.ui.adapter.AibkCognitiveDiagnosisStuNumAdapter
import kotlinx.android.synthetic.main.aibk_dialog_estimate_grade_student_interval_list.*

class DialogCognitiveDiagnosisStuNumList (
        context: Context?,
        val classStuCognitiveDiagnosisInfor: ClassStuCognitiveDiagnosisInfor
) : Dialog(context!!, R.style.CustomDialog) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.aibk_dialog_student_interval_list)
        window!!.setGravity(Gravity.BOTTOM) //设置弹窗右对齐
        window!!.setWindowAnimations(R.style.MyDialogBottomTranslate) //设置动画效果

        val wl = window!!.attributes
        //以下这两句是为了保证按钮可以水平满屏
        wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
        wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        onWindowAttributesChanged(wl)
        setCanceledOnTouchOutside(true)

        //初始化界面数据
        initView()
    }

    /**
     * 初始化界面控件的显示数据
     */
    private fun initView() {

        //关闭dialog
        IvCloseDialog.setOnClickListener {
            dismiss()
        }

        val distreIndex = classStuCognitiveDiagnosisInfor.DistreIndex
        TvTitleStuIntervalList.text = "班级平均认知指数"+distreIndex+"学生名单"

        val manager = LinearLayoutManager(context)
        manager.orientation = LinearLayoutManager.VERTICAL
        RvStuIntervalList.layoutManager = manager
        val mAdapter = AibkCognitiveDiagnosisStuNumAdapter(context, classStuCognitiveDiagnosisInfor)
        RvStuIntervalList.adapter = mAdapter

    }

}